clear all
use "Data\W5 (Finaldata Post-Imputation).dta"

****Table 4 The Results of The Causal Mediation Analysis (CMA)*****
medeff (logit Understanding_of_Democracy Political_Values Family_Values Social_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income)(regress Democratic_Priority Political_Values Understanding_of_Democracy Family_Values Social_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income) ,mediate(Understanding_of_Democracy) treat(Political_Values) sims(1000)

medeff (logit Understanding_of_Democracy Political_Values Family_Values Social_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income)(regress Democratic_Necessity Political_Values Understanding_of_Democracy Family_Values Social_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income) ,mediate(Understanding_of_Democracy) treat(Political_Values) sims(1000)

medeff (logit Understanding_of_Democracy Social_Values Political_Values Family_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income)(regress Democratic_Priority Social_Values Understanding_of_Democracy Political_Values Family_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income) ,mediate(Understanding_of_Democracy) treat(Social_Values) sims(1000)

medeff (logit Understanding_of_Democracy Social_Values Political_Values Family_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income)(regress Democratic_Necessity Social_Values Understanding_of_Democracy Political_Values Family_Values Country_Economic_Evaluation Family_Economic_Evaluation Social_Capital Political_Interest Political_Efficiency Election_Participation Internet_Use gender age education residence employment family_status household_income) ,mediate(Understanding_of_Democracy) treat(Social_Values) sims(1000)


****Since the medeff command cannot output the result we want directly, we manually construct file table4 by putdocx according to the output result in Results Window of stata.*****
putdocx begin
putdocx paragraph, style(Heading1)
putdocx paragraph, font("Times New Roman", 12, black)
putdocx text ("Table 4 The Results of The Causal Mediation Analysis (CMA)") 
putdocx table mytable = (13, 5)

putdocx table mytable(1, 1) = ("Treatment"), font("Times New Roman")  
putdocx table mytable(1, 2) = ("Outcome"), font("Times New Roman")  
putdocx table mytable(1, 3) = ("Effect"), font("Times New Roman")  
putdocx table mytable(1, 4) = ("95% Confidence Interval Lower"), font("Times New Roman")  
putdocx table mytable(1, 5) = ("95% Confidence Interval Upper"), font("Times New Roman")  

putdocx table mytable(2, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(2, 2) = ("Democratic priority"), font("Times New Roman")  
putdocx table mytable(2, 3) = ("ACME"), font("Times New Roman")  
putdocx table mytable(2, 4) = (-0.0072404), font("Times New Roman")  
putdocx table mytable(2, 5) = (-0.0026362), font("Times New Roman")

putdocx table mytable(3, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(3, 2) = ("Democratic priority"), font("Times New Roman")  
putdocx table mytable(3, 3) = ("Direct Effect")  , font("Times New Roman")  
putdocx table mytable(3, 4) = (-0.0908195)  , font("Times New Roman")  
putdocx table mytable(3, 5) = (-0.031526), font("Times New Roman")  

putdocx table mytable(4, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(4, 2) = ("Democratic priority"), font("Times New Roman")  
putdocx table mytable(4, 3) = ("Total Effect"), font("Times New Roman")  
putdocx table mytable(4, 4) = (-0.095612), font("Times New Roman")  
putdocx table mytable(4, 5) = (-0.0366977)  , font("Times New Roman")  



putdocx table mytable(5, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(5, 2) = ("Democratic Necessity"), font("Times New Roman")  
putdocx table mytable(5, 3) = ("AME")   , font("Times New Roman")  
putdocx table mytable(5, 4) = (-0.0057364)  , font("Times New Roman")  
putdocx table mytable(5, 5) = (-0.0024956)  , font("Times New Roman")  

putdocx table mytable(6, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(6, 2) = ("Democratic Necessity"), font("Times New Roman")  
putdocx table mytable(6, 3) = ("ADE")    , font("Times New Roman")  
putdocx table mytable(6, 4) = (-0.164759)  , font("Times New Roman")  
putdocx table mytable(6, 5) = (-0.129541)  , font("Times New Roman")  

putdocx table mytable(7, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(7, 2) = ("Democratic Necessity"), font("Times New Roman")  
putdocx table mytable(7, 3) = ("Total Effect")  , font("Times New Roman")  
putdocx table mytable(7, 4) = (-0.1688663)  , font("Times New Roman") 
putdocx table mytable(7, 5) = (-0.139079)  , font("Times New Roman")  



putdocx table mytable(8, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(8, 2) = ("Democratic priority"), font("Times New Roman")  
putdocx table mytable(8, 3) = ("ACME")   , font("Times New Roman") 
putdocx table mytable(8, 4) = (-0.0071474)  , font("Times New Roman")  
putdocx table mytable(8, 5) = (-0.0025205)  , font("Times New Roman")  

putdocx table mytable(9, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(9, 2) = ("Democratic priority"), font("Times New Roman")  
putdocx table mytable(9, 3) = ("Direct Effect")   , font("Times New Roman")  
putdocx table mytable(9, 4) = (-0.1066915)  , font("Times New Roman") 
putdocx table mytable(9, 5) = (-0.0436527)  , font("Times New Roman")  

putdocx table mytable(10, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(10, 2) = ("Democratic priority"), font("Times New Roman")  
putdocx table mytable(10, 3) = ("Total Effect")    , font("Times New Roman")  
putdocx table mytable(10, 4) = (-0.1114248)  , font("Times New Roman")  
putdocx table mytable(10, 5) = (-0.0485153), font("Times New Roman")  



putdocx table mytable(11, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(11, 2) = ("Democratic Necessity"), font("Times New Roman")  
putdocx table mytable(11, 3) = ("ACME")   , font("Times New Roman")  
putdocx table mytable(11, 4) = (-0.0057142)  , font("Times New Roman")  
putdocx table mytable(11, 5) = (-0.0023836)  , font("Times New Roman")  

putdocx table mytable(12, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(12, 2) = ("Democratic Necessity"), font("Times New Roman")  
putdocx table mytable(12, 3) = ("Direct Effect")  , font("Times New Roman")  
putdocx table mytable(12, 4) = (-0.1200466)  , font("Times New Roman")  
putdocx table mytable(12, 5) = (-0.0825362)  , font("Times New Roman")  

putdocx table mytable(13, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(13, 2) = ("Democratic Necessity"), font("Times New Roman")  
putdocx table mytable(13, 3) = ("Total Effect")   , font("Times New Roman")  
putdocx table mytable(13, 4) = (-0.124355)  , font("Times New Roman")  
putdocx table mytable(13, 5) = (-0.0867339)  , font("Times New Roman")

putdocx save "Results/Tables/Table 4 The Results of The Causal Mediation Analysis (CMA).docx", replace 
